﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>派送员订单管理信息</title>
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/demo.css">
    <link href="~/Content/Styles/Manage_Order.css" rel="stylesheet" />
    <script type="text/javascript" src="~/Content/jquery-easyui-1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="~/Content/jquery-easyui-1.4.2/jquery.easyui.min.js"></script>
    <script src="~/Content/jquery-easyui-1.4.2/locale/easyui-lang-zh_CN.js"></script>
     <script type="text/javascript">
         $(function () {
             GetMer();//加载操作员管理的所有商户
             initTable1();
             mertype();
         })
         var FormBY = "";
         var Mer;//商户ID
         var diplayText;//商户名称

         //获取商户
         function GetMer() {
             var grid = $('#SearchMer').combogrid({
                 panelWidth: 500,
                 idField: 'MerID',
                 textField: 'MerName',
                 url: '/TakerSend/InitMerID',
                 method: 'post',
                 pageSize: 5,
                 pageList: [5],
                 pagination: true,
                 rownumbers: true,
                 fitColumns: true,
                 columns: [[
                     { field: 'MerID', title: '商户ID', width: 80, align: 'center' },
                     { field: 'MerName', title: '商户名称', width: 80, align: 'center' },
                     { field: 'MerTxt', title: '商户介绍', width: 120, align: 'center' },
                     { field: 'MerAdr', title: '商户地址', width: 80, align: 'center' },
                     { field: 'MerCall', title: '商户联系电话', width: 80, align: 'center' }
                 ]],
                 onSelect: function (index, row) {
                     diplayText = row[grid.combogrid('options').textField];
                     Mer = $('#SearchMer').combogrid("getValue");//获取操作员
                     //加载对应派送员订单
                     initTable(Mer);
                     
                 },
                 onLoadSuccess: function () {
                     //分页后判断下是否有选中的数据行，combogrid会依据上一次选中的值进行初始化，选中datagrid数据行和设置显示值
                     if (!grid.combogrid('grid').datagrid('getSelected'))//不在当前页
                     {
                         $('#SearchMer').combogrid("setValue", diplayText);
                     }
                 }
             });
         }

        
      
         //派送员订单信息datagrid
         function initTable(item) {
             $('#View').datagrid({
                 iconCls: 'icon-user',
                 loadMsg: '数据加载中...',
                 fitColumns: true,
                 nowrap: true,
                 autoRowHeight: true,
                 striped: true,
                 url: '/TakerSend/View_TakerForm?MerID=' + item,
                 //sortName: 'FormID',
                 sortOrder: 'asc',
                 border: true,
                 remoteSort: false,
                 singleSelect: true,
                 idField: 'FormID',
                 pagination: true,
                 rownumbers: true,
                 columns: [[
                     { field: 'TakerName', title: '派送员', sortable: true },
                     { field: 'TakerPhone', title: '派送员电话', sortable: true },
                     { field: 'FormID', title: '派送订单ID', sortable: true },
                     { field: 'ConText', title: '订单状态', sortable: true },
                     { field: 'AccName', title: '客户姓名', sortable: true },
                     { field: 'AccCall', title: '客户电话', sortable: true },
                     { field: 'FormDisheName', title: '菜品名', sortable: true },
                     { field: 'FormPayMon', title: '实际', sortable: true },
                     { field: 'FormAddress', title: '配送地址', sortable: true },
                     {
                         field: 'SenTime', title: '送餐时间',sortable: true , formatter: function (val, rowdata, index) {
                             if (val == 0) {
                                 return '立刻送餐'
                             }
                             else {
                                 return val;
                             }
                         }
                     },
                     //{ field: 'FormTime', title: '订单生成时间' },
                     { field: 'IntBZ', title: '备注', sortable: true },
                 ]],
                 toolbar: '#tb1',
             });
         }

         //检索
         function Search() {
             var TakerName = $('#TakerName').textbox("getValue"); 
             var FormNum = $('#FormNum').textbox("getValue");
             var FormTimeS = $('#FormTimeS').datebox('getValue');
             var FormTimeE = $('#FormTimeE').datebox('getValue');
             //if (FormControl != "" || FormTimeS != "" || FormTimeE != "") {
             if (FormTimeS > FormTimeE) {
                 $.messager.alert("友情提示", "开始日期不能大于结束日期");
             }
             else {
                 $('#View').datagrid({
                     url: '/TakerSend/View_TakerForm?Merid=' + Mer + "&TakerName=" + TakerName + "&Formid=" + FormNum + "&stime=" + FormTimeS + "&etime=" + FormTimeE,
                 });
             }
             //}
             //else {
             //    $.messager.alert("友情提示", "请输入搜索条件");
             //}

         }




         //商品信息明细对话话框
         function DetailDialog() {

             var UpdateInfoID = $("#View").datagrid("getSelections");
             if (UpdateInfoID.length == 1) {
                 $("#editDialog").dialog("open").dialog("setTitle", "查看派送订单明细");
                 BingUpdate(0);
             }
             else {
                 $.messager.alert("友情提示", "每次只能查看一行数据，你已经选择了<font color='red' size='6'>" + UpdateInfoID.length + "</font>行");
             }
         }
         //订单信息明细界面赋值
         function BingUpdate(IsButton) {
             $("#MerBZ").textbox("setValue", "");
             document.getElementById("SaveButton").innerHTML = "";
             //首先获取选中的商品订单
             var checkdata = $("#View").datagrid("getSelections")[0];
             if (checkdata != null) {
                 
                 $("#TakerName1").textbox('setValue', checkdata.TakerName);
                 $("#TakerPhone").textbox('setValue', checkdata.TakerPhone);
                 
                 var FormPayType = checkdata.FormPayType;
                 switch (checkdata.FormPayType) {
                     case 0:
                         FormPayType = "现金";
                         break
                     case 1:
                         FormPayType = "钱包支付";
                         break
                     case 2:
                         FormPayType = "第三方支付";
                         break
                 }
                 var IsPay = checkdata.IsPay;
                 switch (checkdata.IsPay) {
                     case 0:
                         IsPay = "未支付";
                         break
                     case 2:
                         IsPay = "已支付";
                         break
                     case 3:
                         IsPay = "支付失败";
                         break
                     case 4:
                         IsPay = "现金支付";
                         break
                 }
                 var FormBY = checkdata.FormBY;  //订单状态;
                 var SenTime = checkdata.SenTime;
                 var FormTime = checkdata.FormTime;
                 if (IsButton == 1) {
                     AddButton(FormBY);
                 }
                
                 $("#FormBY").text(checkdata.ConText);
                 $("#FormID").textbox('setValue', checkdata.FormID);
                 $("#FormTime").textbox('setValue', FormTime);
                 $("#FormPayType").textbox('setValue', FormPayType);
                 $("#ConText").textbox('setValue', checkdata.ConText);
                 $("#SenTime").textbox('setValue', SenTime);
                 $("#AccCall").textbox('setValue', checkdata.AccCall);
                 $("#AccName").textbox('setValue', checkdata.AccName);
                 $("#FormAddress").textbox('setValue', checkdata.FormAddress);
                 //$("#DelFormMon").textbox('setValue', checkdata.DelFormMon * 0.01);
                 //$("#DelPackMon").textbox('setValue', checkdata.DelPackMon * 0.01);
                 //if (checkdata.IsEva == 0)
                 //{ $("#IsEva").attr("checked", ''); }
                 //if (checkdata.IsEva == 1) {
                 //    $("#IsEva").attr("checked", true);
                 //}
                 //$("#FormPreMon").textbox('setValue', checkdata.FormPreMon * 0.01) //优惠
                 //$("#FormPayMon").textbox('setValue', checkdata.FormPayMon * 0.01) //实际支付
                 ////$("#FormPayInt").numberbox('setValue', checkdata.FormPayInt) //消费积分
                 //$("#IntBZ").textbox('setValue', checkdata.IntBZ) //备注
             }
         }
        </script>
</head>
<body  style="padding: 0px">
    <div style="padding:5px; background-color:#F4F4F4">
        <div >
            <a>商户：</a>
            <input id="SearchMer" class="easyui-combogrid" style="width: 120px" />
        </div>
    </div>
    <div >
        <table id="View"></table>
    </div>
    <div id="tb1" style="background-color:#F4F4F4">
        <div style="margin-bottom: 5px;">
            <a href="#" class="easyui-linkbutton" id="btndetail" iconcls="icon-more" onclick="DetailDialog()" plain="true">明细</a>
        </div>
        <div>
            <a>派送员：</a>
            <input id="TakerName" class="easyui-textbox" style="width: 120px" />
             <a>派送订单号：</a>
            <input id="FormNum" class="easyui-textbox" style="width: 120px" />
            <a>派送时间：</a>
            <input id="FormTimeS" class="easyui-datebox" style="width: 120px" />
            <a>至</a>
            <input id="FormTimeE" class="easyui-datebox" style="width: 120px" />
            <a href="#" class="easyui-linkbutton" iconcls="icon-search" onclick="Search()" plain="true">检索</a>
        </div>
    </div>
    <div id="editDialog" class="easyui-dialog" style="width:800px; padding: 10px; height:250px; padding:fixed; top:5px;" closed="true" resizable="true" modal="true" buttons="#dlg-buttons" align="center">
        <form id="editController" method="post" style="padding:10px" novalidate="novalidate">
            <table width="700" id="tbledit" >
                 <tr>
                    <td colspan="5" align="center"; class="userinfo-td-r">
                        <a style="font-size:25px;color:red;text-decoration:none" id="FormBY" ></a>
                    </td>
                </tr>
                <tr>
                    <td  class="userinfo-td-l">派送员：</td>
                    <td width="200" class="userinfo-td-r">
                        <input class="easyui-textbox" type="text" readonly="true" id="TakerName1" name="TakerName" />
                    </td>
                    <td></td>
                    <td class="userinfo-td-l">派送员电话：</td>
                    <td width="200" class="userinfo-td-r">
                        <input class="easyui-textbox" type="text" readonly="true" id="TakerPhone" name="TakerPhone" />
                    </td>
                </tr>
                <tr>
                    <td class="userinfo-td-l">派送订单号：</td>
                    <td width="200" class="userinfo-td-r">
                        <input class="easyui-textbox" type="text" readonly="true" id="FormID" name="FormID" />
                    </td>
                    <td></td>
                    <td  class="userinfo-td-l">订单状态：</td>
                    <td width="200" class="userinfo-td-r">
                        <input class="easyui-textbox" type="text" readonly="true" id="ConText" name="ConText" /></td>
                   
                </tr>
                <tr style="display:none">
                     <td width="100" class="userinfo-td-l">下单时间：</td>
                    <td width="200" class="userinfo-td-r">
                        <input class="easyui-textbox" type="text" readonly="true" id="FormTime" name="FormTime" />
                    </td>
                    <td></td>
                    <td  class="userinfo-td-l">支付状态：</td>
                    <td class="userinfo-td-r">
                        <input class="easyui-textbox" type="text" readonly="true" id="IsPay" name="IsPay" /></td>
                </tr>
                <tr>
                    <td  class="userinfo-td-l">客户姓名：</td>
                    <td  class="userinfo-td-r">
                        <input class="easyui-textbox" type="text" readonly="true" id="AccName" name="AccName" /></td>
                    
                    <td></td>
                    <td class="userinfo-td-l">联系方式：</td>
                    <td class="userinfo-td-r">
                        <input class="easyui-textbox" type="text" readonly="true" id="AccCall" name="AccCall" /></td>
                </tr>
                <tr>
                    <td class="userinfo-td-l">送餐时间：</td>
                    <td class="userinfo-td-r">
                        <input class="easyui-textbox" type="text" readonly="true" id="SenTime" name="SenTime" /></td>
                    <td></td>
                </tr>
                <tr>
                    <td class="userinfo-td-l">送餐地点：</td>
                    <td class="userinfo-td-r"  colspan="4">
                        <input class="easyui-textbox"  type="text" readonly="true" id="FormAddress" name="FormAddress" style="width:500px" /></td>
                </tr>
                <tr></tr>
                @*<tr style="text-align:center">
                    <td colspan="5">
                        <table class="easyui-datagrid" id="tableDishes" style="width: 700px; height:190px; padding: 0px;" data-options="fitColumns: false">
                            <thead>
                                <tr>
                                    <th data-options="field:'FormDisheName',width:178,align:'center'">商品名称</th>
                                    <th data-options="field:'FormDishesMon',width:120,align:'center'">单价</th>
                                    <th data-options="field:'FornDishesInt',width:120,align:'center'">积分</th>
                                    <th data-options="field:'FormDishesNun',width:120,align:'center'">数量</th>
                                    <th data-options="field:'FornDishesCount',width:129,align:'center'">总计</th>
                                </tr>
                            </thead>
                        </table>
                    </td>
                </tr>*@
                 <tr></tr>
                  @*<tr><td>
                      <a style="padding-right:35px;color:red" >
                         <input type="checkbox" id="IsEva" readonly="true" disabled="disabled" name="IsEva">是否评价</input>
                            </a>
                      </td>

                  </tr>*@
                @*<tr>
                    <td colspan="5">
                        
                        <a class="userinfo-td-l">已优惠：</a>
                        <a class="userinfo-td-r">
                            <input class="easyui-textbox" style="width: 80px" type="text" id="FormPreMon" readonly="true" name="FormPreMon" />
                        </a>
                        <a class="userinfo-td-l" style="padding-right:35px">元</a>
                        <a class="userinfo-td-l">实际支付金额：
                        </a>
                        <a class="userinfo-td-r">
                            <input class="easyui-textbox" style="width: 80px"  type="text"  id="FormPayMon" readonly="true" name="FormPayMon" />
                        </a>
                        <a class="userinfo-td-l" style="padding-right:35px">元</a>
                        <a class="userinfo-td-l">消耗积分：
                        </a>
                        <a class="userinfo-td-r">
                            <input class="easyui-numberbox" style="width: 80px" type="text" id="FormPayInt" readonly="true" name="FormPayInt" />
                        </a>
                        <a class="userinfo-td-l">分</a>
                    </td>
                </tr>*@
                  @*<tr><td colspan="5">
                      <a class="userinfo-td-l">包装费：</a>
                        <a class="userinfo-td-r">
                            <input class="easyui-textbox" style="width: 80px" type="text" id="DelPackMon" readonly="true" name="DelPackMon" />
                        </a>
                        <a class="userinfo-td-l" style="padding-right:35px">元</a>
                      <a class="userinfo-td-l">配送费：</a>
                        <a class="userinfo-td-r">
                            <input class="easyui-textbox" style="width: 80px;" type="text" id="DelFormMon"   name="DelFormMon" />
                        </a>
                        <a class="userinfo-td-l" style="padding-right:35px">元</a>
                      </td>
                  </tr>*@
                <tr>
                    @*<td colspan="5">
                        <a class="userinfo-td-l" style="padding-bottom:10px">客户备注：</a>
                        <input class="easyui-textbox" data-options="multiline:true"  style="width:700px;height:50px;" type="text" id="IntBZ" name="IntBZ" readonly="true"/>
                        <a class="userinfo-td-l" style="padding-bottom:10px">商家补充备注：</a>
                        <input class="easyui-textbox" type="text" data-options="multiline:true"  style="width:700px;height:50px;" id="MerBZ" name="MerBZ"/>
                    </td>*@
                </tr>
            </table>

            <div align="right" id="SaveButton" style="padding-right:68px">
            </div>
        </form>
    </div>
    </body>
</html>